import request from '../../utils/request';
import config from '../../utils/config';

const { api } = config;
const { produt: {
  findSecurityInfos,
  findIndexQuotationTrends,
} } = api;

type FindSecurityInfosInput = {
	keyword?: string, // 搜索词
}
type FindSecurityInfosOutput = {
  code: number,
  note: string,
  records: {
		scrCode: string,	//证券代码
		scrName: string,	//证券名称
	}[]
};
// 查询证券代码
export async function FindSecurityInfos(payload: FindSecurityInfosInput): Promise<FindSecurityInfosOutput> {
  const option = {
    url: findSecurityInfos, // crm/v1/product/security/search
    method: 'GET',
    data: payload,
  };
  return request(option);
}

type FindIndexQuotationTrendsInput = {
	indxCode: string, // 指数代码
	strtDate?: string, // 开始日期
	endDate?: string, // 结束日期
}
type FindIndexQuotationTrendsOutput = {
  code: number,
  note: string,
  records: {
		date: string,	//日期
		indxCode: string,	//指数代码
		indxVal: string,	//指数值
	}[]
};
// 查询指数行情走势
export async function FindIndexQuotationTrends(payload: FindIndexQuotationTrendsInput): Promise<FindIndexQuotationTrendsOutput> {
  const option = {
    url: findIndexQuotationTrends, // crm/v1/product/index/quotation/trend
    method: 'GET',
    data: payload,
  };
  return request(option);
}
